import commonService from 'service/common';
export default {
    // 话术列表
    async list(data, search_data) {
        if (!search_data) {
            search_data = []
        }
        let dataObj = {
            "group": {
                "filters": [{
                    "queryOperator": "EQ",
                    "searchName": "string",
                    "value": {}
                }],
                "groups": [
                    {}
                ],
                "operator": "AND"
            },
            "page": {
                "pageNumber": data.pageNumber,
                "pageSize": data.pageSize,
                "sort": [{
                    "direction": "ASC",
                    "property": "id"
                }]
            }
        };
        let paramsJson = {
            baseURL: '/8third',
            method: 'post',
            url: 'common/words/search',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //我的话术
    async myWord(userid) {
        let paramsJson = {
            baseURL: '/8third',
            method: 'get',
            url: 'common/words/my/' + userid
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 添加话术
    async add(data) {
        let dataObj = Object.assign({
            startWord: '',
            endWord: '',
            users: [],
            name: ""
        }, data)
        let paramsJson = {
            baseURL: '/8third',
            method: 'post',
            url: 'common/words',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //删除
    async delete(id) {
        let paramsJson = {
            baseURL: '/8third',
            method: 'delete',
            url: 'common/words/' + id
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 查询组织架构
    async getOrganizationList(data) {
        let dataObj = Object.assign({

        }, data)

        let paramsJson = {
            baseURL: '/webapiThird',
            method: 'get',
            url: 'webapi/organization/list',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 根据id查询架构下的人
    async getOrganizationPerson(data) {
        let dataObj = Object.assign({
            orgIdList: ""
        }, data)
        let paramsJson = {
            baseURL: '/webapiThird',
            method: 'get',
            url: 'webapi/user/listByOrgId',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    }
}